package Server;

import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TBinaryProtocol.Factory;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.server.TNonblockingServer;
import org.apache.thrift.server.TServer;
import org.apache.thrift.transport.TNonblockingServerSocket;
import org.apache.thrift.transport.TNonblockingServerTransport;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;

import com.amos.thrift.demo.HelloWorldService;

public class TestUserStorage implements HelloWorldService.Iface {
	 public static void main(String[] as) {
		   TNonblockingServerTransport serverTransport = null;
		
	        try{
	        	  serverTransport = new TNonblockingServerSocket(8088);
	        }catch(TTransportException e1) {
	            // TODO Auto-generated catch block
	            e1.printStackTrace();
	        }
	        HelloWorldService.Processor<HelloWorldService.Iface> processor = new HelloWorldService.Processor<HelloWorldService.Iface>(new TestUserStorage());

	           Factory protFactory = new TBinaryProtocol.Factory(true, true);

	      

	           TNonblockingServer.Args args = new TNonblockingServer.Args(

	                serverTransport);

	           args.processor(processor);

	           args.protocolFactory(protFactory);

	           TServer server = new TNonblockingServer(args);

	           System.out.println("Start server on port 8087 ...");

	           server.serve();
	              
	    }

	@Override
	public String sayHello(String username) throws TException {
		// TODO Auto-generated method stub
		System.out.println("name===>"+username);
		return "ddddd";
	}
	
	/*@Override
	public boolean addUser(User user) throws TException {
		// TODO Auto-generated method stub
		System.out.println("hello");
		return false;
	}*/
	           
}
